package com.jic.manager.controller.manage.entryterms;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.manager.entity.MeentryTerms;
import com.jic.manager.request.MeentryTermsRequest;
import com.jic.manager.service.MeentryTermsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("entryTerms")
public class MEntryTermsController {
    @Autowired
    private MeentryTermsService mEntryTermsService;
    //查询入驻条款列表
    @PostMapping(value = "/queryEntryTermsList")
    public RestResult<PageResult<MeentryTerms>> queryEntryTermsList(@RequestBody MeentryTermsRequest meentryTermsRequest)  {
        PageResult<MeentryTerms> meentryTermsPageResult = mEntryTermsService.queryPage(meentryTermsRequest);
        return RestResult.success(meentryTermsPageResult);
    }

    //根据条件查询入驻条款信息
    @PostMapping(value = "/getTermsInfoByParams")
    public RestResult<MeentryTerms> getTermsInfoByParams(@RequestBody MeentryTerms meentryTerms){
        MeentryTerms meentryTerms1 = mEntryTermsService.getTermsInfo(meentryTerms);
        return RestResult.success(meentryTerms1);
    }

    //新增入驻条款列表
    @PostMapping(value = "editEntryTermsInfo")
    public RestResult<String> editEntryTermsInfo(@RequestBody MeentryTermsRequest meentryTermsRequest){
        return mEntryTermsService.editEntryTermsInfo(meentryTermsRequest);
    }

   //删除入驻条款
   @PostMapping(value = "deleteEntryTerms")
   public RestResult<String> deleteDept(@RequestBody MeentryTermsRequest meentryTermsRequest){
       return mEntryTermsService.deleteEntryTerms(meentryTermsRequest.getIds());
   }

   //启动/停用条款
    @PostMapping(value = "startTerms")
    public RestResult<String> startTerms(@RequestBody MeentryTermsRequest meentryTermsRequest){
         mEntryTermsService.update(meentryTermsRequest);
         return RestResult.success("成功");
    }
}
